//
//  CRChelpCenterProblemControllerViewController.m
//  jinyishe
//
//  Created by 金艺社 on 2018/2/24.
//  Copyright © 2018年 wy. All rights reserved.
//
/*
 功能与帮助中心相似，使用帮助中心的代码。只做数据改动，重写相关方法。
 */
#import "CRChelpCenterProblemControllerViewController.h"
#import "NetworkManager.h"
#import "CRChelpCenterUrl.h"
#import <MJExtension/MJExtension.h>
#import "GKLHelpCenterModel.h"
#import "GKHelpTitleCell.h"
#import "GKLHelpCenterCell.h"
@interface CRChelpCenterProblemControllerViewController ()

@end

@implementation CRChelpCenterProblemControllerViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    [self confingureRefresh];
    self.title = @"问题解释";
    [self beginHeaderRefreshing];
    [self confingureNav];
}
- (void)confingureNav
{
   
}
#pragma mark - net

- (void)handleHelpCenterRequestWithPage:(NSUInteger)page
{
    __weak typeof(self) weakSelf = self;
    [[NetworkManager defaultManager] getWithURLString:[CRChelpCenterUrl helpProblem:_touchSection] parameters:nil success:^(id responseObject) {
        [self endFooterRefresh];
        [self endHeaderRefresh];
        if ([responseObject[@"rcd"] isEqualToString:kNetResponse_R0001]) {
            [weakSelf handleResponseData:responseObject];
        }
    } failure:^(NSError *error) {
        [self endFooterRefresh];
        [self endHeaderRefresh];
    }];
    
    
}

- (void)handleResponseData:(NSDictionary *)responseObject
{
    if (self.isHeaderRefreshing) {
        [self.dataArray removeAllObjects];
    }
    NSMutableArray *modelArray = [GKLHelpCenterModel mj_objectArrayWithKeyValuesArray:responseObject[@"articleItemList"]];
    if (modelArray.count) {
        [self.dataArray addObjectsFromArray:modelArray];
    }
    NSUInteger pageTotal = [[responseObject[@"pageBean"] valueForKey:@"totalCount"] integerValue];
    
    [self reloadTableWithPageTotal:pageTotal];
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
